package com.jiexinyun.controller.android;

import com.jiexinyun.dto.request.androidworktask.*;
import com.jiexinyun.dto.response.AjaxResult;
import com.jiexinyun.service.android.PublicWorkTaskService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;

@Slf4j
@RestController
@RequestMapping("/public/work/task")
@Tag(name = "安卓工作机公开接口-机台任务", description = "安卓工作机公开接口-机台任务")
@Valid
public class PublicWorkTaskController {

    @Autowired
    private PublicWorkTaskService service;

    /**
     * 需要登录状态，保存任务的时候才需要登录
     * @param req
     * @return
     */
    @PostMapping("/queryWorkTaskByCode")
    @Operation(summary = "查询生产任务-按照码值", description = "查询生产任务-按照码值")
    public AjaxResult queryWorkTaskByCode(@Valid @RequestBody QueryWorkTaskByCodeReq req) {
        return service.queryWorkTaskByCode(req);
    }

    @PostMapping("/queryWorkTaskList")
    @Operation(summary = "查询机台生产任务列表", description = "查询机台生产任务列表")
    public AjaxResult queryWorkTaskList(@Valid @RequestBody WorkTaskListReq req) {
        return service.queryWorkTaskList(req);
    }

    @PostMapping("/saveWorkTask")
    @Operation(summary = "保存机台任务", description = "保存机台任务")
    public AjaxResult saveWorkTask(@Valid @RequestBody SaveWorkTaskReq req) throws Exception {
        return service.saveWorkTask(req);
    }

    /**
     * 去
     * @param req
     * @return
     */
    @PostMapping("/queryWorkTaskRegByCode")
    @Operation(summary = "查询登记任务-单条按照工步码查询", description = "查询登记任务-单条按照工步码查询")
    public AjaxResult queryWorkTaskRegByCode(@Valid @RequestBody QueryWorkTaskRegByCodeReq req) {
        return service.queryWorkTaskRegByCode(req);
    }

    @PostMapping("/queryWorkTaskRegList")
    @Operation(summary = "查询机台产出任务列表", description = "查询机台产出任务列表")
    public AjaxResult queryWorkTaskRegList(@Valid @RequestBody WorkTaskRegListReq req) {
        return service.queryWorkTaskRegList(req);
    }

    @PostMapping("/goWorkTaskReg")
    @Operation(summary = "上报产出登记", description = "上报产出登记")
    public AjaxResult goWorkTaskReg(@Valid @RequestBody GoWorkTaskReq req) {
        return service.goWorkTaskReg(req);
    }

    @PostMapping("/tuzhi")
    @Operation(summary = "图纸", description = "图纸")
    public AjaxResult tuzhi(@Valid @RequestBody QueryTuzhiReq req) {

        return service.tuzhi(req);
    }

}
